var t = getApp();

Page({
    data: {
        language: "",
        selected: 0,
        selectedidx: "1",
        isPresenter: !1,
        types: [],
        typesIndex: 0,
        couponListData: [],
        colors: [ "#fbbd5c", "#ff8383", "#a291ff", "#f095ed", "#6dccf8", "#fb946c", "#cecece" ],
        memberId: ""
    },
    onLoad: function(t) {
        t.id && this.setData({
            memberId: t.id
        }), this._initData(), this._getNetData(1, this.data.typesIndex);
    },
    _initData: function() {},
    onReady: function() {},
    switchItem: function(t) {
        var e = t.detail.index;
        e + 1 != this.data.selectedidx && (0 == e ? this.setData({
            selectedidx: "1"
        }) : 1 == e ? this.setData({
            selectedidx: "2"
        }) : 2 == e && this.setData({
            selectedidx: "3"
        }), this._initData(), this._getNetData(this.data.selectedidx, this.data.typesIndex));
    },
    setTypesIndex: function(t) {
        var e = t.currentTarget.dataset.index;
        e != this.data.typesIndex && (this.setData({
            typesIndex: e
        }), this._getNetData(this.data.selectedidx, e));
    },
    onShow: function() {},
    onHide: function() {},
    _getNetData: function(e, a) {
        this.setData({
            couponListData: []
        });
        var s = this, o = t.getNetAddresss("plugin.shop-assistant.frontend.coupon.coupon-list");
        o += "&uid=" + this.data.memberId, o += "&status_request=" + e, o += "&coupon_type=" + a, 
        t._getNetWork({
            url: o,
            success: function(e) {
                var a = e.data;
                if (1 == a.result) {
                    var o = a.data;
                    if (s.data.total_page = a.data.total ? a.data.total : 0, s.data.couponListDataSet = o.data, 
                    a.data.set && s.setData({
                        isPresenter: a.data.set.transfer
                    }), a.data.search_array) {
                        s.setData({
                            types: a.data.search_array || []
                        });
                        for (var n = 0; n < o.list.length; n++) "门店商品" == o.list[n].belongs_to_coupon.coupon_type_name ? o.list[n].type = 6 : "平台商品" == o.list[n].belongs_to_coupon.coupon_type_name ? o.list[n].type = 1 : "兑换券" == o.list[n].belongs_to_coupon.coupon_type_name ? o.list[n].type = 2 : "分类商品" == o.list[n].belongs_to_coupon.coupon_type_name ? o.list[n].type = 3 : "指定商品" == o.list[n].belongs_to_coupon.coupon_type_name ? o.list[n].type = 4 : "酒店商品" == o.list[n].belongs_to_coupon.coupon_type_name ? o.list[n].type = 5 : "商品和门店" == o.list[n].belongs_to_coupon.coupon_type_name && (o.list[n].type = 8);
                    }
                    s.setData({
                        couponListData: o.list
                    });
                } else t.tips(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});